package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * 酒店地区 syy
 */
@Getter
@Setter
public class Area extends BaseDomain {

    public static final int STATE_NORMAL = 0;
    public static final int STATE_HOT = 1;

    private String name;//地区名称

    private Long parentId;//关联父级id

    private Integer state = STATE_NORMAL;//地区状态

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("parentId",parentId);
        map.put("state",state);
        return JSONUtils.toJSONString(map);
    }

    public Map<String,Object> changeToMap(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",getId());
        map.put("lazyLoad",true);
        map.put("text",name);
        if(state==STATE_HOT){
            map.put("tags",new String[]{"推荐"});
        }
        map.put("parentId",parentId);
        map.put("json",getJson());
        return map;
    }

}